import api from '@/api'

const state = {
  'areaOptions': [],
  'productOptions': [],
  'orderTeamOptions': []
}
const mutations = {
  mergeAreaOptions(state, payload) { // 合并选项
    state.areaOptions = payload
  },
  mergeProductOptions(state, payload) { // 合并选项
    state.productOptions = payload
  },
  mergeOrderTeamOptions(state, payload) { // 合并选项
    state.orderTeamOptions = payload
  }
}
const actions = {
  async area_tree_book_list({
    commit
  }, obj) {
    const result = await api.order.tree_book_list(obj)
    if (result.code === 200) {
      commit('mergeAreaOptions', result.data);
    }
    return result
  },
  async product_tree_book_list({
    commit
  }, obj) {
    const result = await api.order.tree_book_list(obj)
    if (result.code === 200) {
      commit('mergeProductOptions', result.data);
    }
    return result
  },
  async get_current_user_handle_order_team({
    commit
  }, obj) {
    const result = await api.order.get_current_user_handle_order_team(obj)
    if (result.code === 200) {
      commit('mergeOrderTeamOptions', result.data);
    }
    return result
  }
}
const getters = {

}

export default {
  namespaced: true,
  state,
  actions,
  mutations,
  getters
}
